<%@page import="cn.jhc.bean.ActBean"%>
<%@page import="cn.jhc.dao.ActivitiesDAO"%>
<%@page import="cn.jhc.dao.NewMsgDAO"%>
<%@page import="cn.jhc.dao.MusicDAO"%>
<%@page import="cn.jhc.dao.ActDAO"%>
<%@page import="cn.jhc.dao.MsgDao"%>
<%@page import="cn.jhc.bean.MsgBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@page import="cn.jhc.dao.NewsDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/news.css"></link>
<style>
* {
	border: 0;
}
table tr:hover{
	background-color:rgba(0,0,0,0.25);
}
</style>
<title>校园新闻</title>
</head>
<body>
	<%
		int CurrentPage = 1;
		int intPageCount;
		if (request.getParameter("page") != null)
			CurrentPage = Integer.parseInt(request.getParameter("page"));
		if (CurrentPage < 1)
			CurrentPage = 1;
		int newsCount = 17;
	%>
	<div id="wrapper">
		<jsp:include page="./header.jsp"></jsp:include>
		<div id="address">
			<a>当前位置： 活动信息</a>
		</div>
		<div id="wrapperdown">
			<%
				ArrayList<ActBean> list = new ArrayList<ActBean>();
				ActivitiesDAO dao = new ActivitiesDAO();
				dao.setCon(ConnectionFactory.getConnection());
				list = dao.getAllActivities(CurrentPage, newsCount);
				request.setAttribute("actnews", list);
			%>
			<%
				ActivitiesDAO dao2 = new ActivitiesDAO();
				dao2.setCon(ConnectionFactory.getConnection());
				intPageCount = dao2.getCount(newsCount);
				if (intPageCount == 0) {
					CurrentPage = 1;
					intPageCount = 1;
				} else {
					if (CurrentPage > intPageCount)
						CurrentPage = intPageCount;
				}
			%>
			<div id="topright">
				<div id="righttop">
					<a>讨论区最新主题</a>
				</div>
				<div id="right_down">
					<%
						ArrayList<MsgBean> m = new ArrayList<MsgBean>();
						MsgDao water = new MsgDao();
						water.setCon(ConnectionFactory.getConnection());
						m = water.getAllMessages(1, 4);
						request.setAttribute("water", m);
					%>
					<%
						ArrayList<MsgBean> a = new ArrayList<MsgBean>();
						ActDAO act = new ActDAO();
						act.setCon(ConnectionFactory.getConnection());
						a = act.getAllMessages(1, 4);
						request.setAttribute("act", a);
					%>
					<%
						ArrayList<MsgBean> b = new ArrayList<MsgBean>();
						MusicDAO music = new MusicDAO();
						music.setCon(ConnectionFactory.getConnection());
						b = music.getAllMessages(1, 4);
						request.setAttribute("music", b);
					%>
					<%
						ArrayList<MsgBean> n = new ArrayList<MsgBean>();
						NewMsgDAO NewMsg = new NewMsgDAO();
						NewMsg.setCon(ConnectionFactory.getConnection());
						n = NewMsg.getAllMessages(1, 4);
						request.setAttribute("News", n);
					%>
					<table width="280" align="left">
						<c:forEach items="${requestScope.water}" var="water">
							<tr>
								<td height="30"><div id="alltitle">
										<img src="images/face.gif"></img><a
											href="showmessages.jsp?id=${water.id}">[灌水区]${water.title}</a>
									</div></td>
							</tr>
						</c:forEach>
						<c:forEach items="${requestScope.act}" var="act">
							<tr>
								<td height="30"><div id="alltitle">
										<img src="images/face.gif"></img><a
											href="showActmessages.jsp?id=${act.id}">[活动专区]${act.title}</a>
									</div></td>
							</tr>
						</c:forEach>
						<c:forEach items="${requestScope.music}" var="music">
							<tr>
								<td height="30"><div id="alltitle">
										<img src="images/face.gif"></img><a
											href="showMusicmessages.jsp?id=${music.id}">[音乐专区]${music.title}</a>
									</div></td>
							</tr>
						</c:forEach>
						<c:forEach items="${requestScope.News}" var="News">
							<tr>
								<td height="30"><div id="alltitle">
										<img src="images/face.gif"></img><a
											href="showNewsmessages.jsp?id=${News.id}">[新闻讨论区]${News.title}</a>
									</div></td>
							</tr>
						</c:forEach>
					</table>
				</div>
				<div id="entertaolunqu">
					<a href="alltaolunqu.jsp">点此进入讨论区>></a>
				</div>
			</div>
			<div id="topall">
				<div id="newsaddress">
					<a>首页>活动信息>列表</a>
				</div>
				<table align="left" width="600">
					<c:forEach items="${requestScope.actnews}" var="act">
						<tr>
							<td height="30"><div id="news">
									<img src="images/jiantou.gif"></img><a> </a><a
										href="activitiescontext.jsp?id=${act.id}">${act.title}</a>
								</div></td>
							<td><div align="center">
									<a>(${act.date})</a>
								</div></td>
						</tr>
					</c:forEach>
				</table>
			</div>
		</div>
		<div id="pagebg"></div>
		<div id="page" align="right">
			<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
			</a> <a href="activities.jsp?page=<%=1%>">首页</a>
			<%
				if (CurrentPage > 1) {
			%>
			<a href="activities.jsp?page=<%=CurrentPage - 1%>">上一页</a>
			<%
				} else {
			%>
			<a>上一页</a>
			<%
				}
			%>
			<%
				if (CurrentPage >= intPageCount) {
			%>
			<a>下一页</a>
			<%
				} else {
			%>
			<a href="activities.jsp?page=<%=CurrentPage + 1%>">下一页</a>
			<%
				}
			%>
			<a href="activities.jsp?page=<%=intPageCount%>">末页</a>
		</div>
		<div id="line2"></div>
		<div id="copyright">
			<a>版权所有:蓝调吉他社 </a><a>| </a>
			<div id="admin">
				<a href="houtai_index.jsp">管理员登录</a>
			</div>
		</div>
	</div>
</body>
</html>
